#pragma once

#include "common.h"
#include "auxilary.h"

struct BodyInfo
{
    BodyInfo () : point (), mass ( 0.0 ), radius ( 0.0 ), velocity () {}
    BodyInfo ( Point2D point, double mass, double radius, Point2D velocity )
        : point ( point ), mass ( mass ), radius ( radius ), velocity ( velocity ) {}

    Point2D point;
    double mass;
    double radius;

    Point2D velocity;
};

class GravityModel
{
public:
    GravityModel ();

    void LoadData ( QString fileName );

    void AddBody ( Point2D point, double radius, double mass, Point2D vel = Point2D ( 0.0, 0.0 ) );
    void SetTimeInterval ( double dt );

    void CalcStep();
    
    int GetBodyCount();
    void GetBodyPos ( int index, Point2D & point );

    Point2D GetMassCenter();

private:
    vector<BodyInfo> bodyInfoVect;
    vector<Point2D> forceVect;
    double dt;
    Point2D massCenter;
    double wholeMass;
};
